//
//  AppDelegate.swift
//  HisPaste
//
//  Created by 烟雀 on 2024/2/16.
//

import Foundation
import SwiftUI
import Carbon

class AppDelegate: NSObject, NSApplicationDelegate{
    
    let menu = MenuButton()
    
    var hisViewWin: NSWindow?
    
    public func applicationDidFinishLaunching(_ notification: Notification){
//        if !AppHelper.hasAccess(){
//            #if DEBUG
//            print("可能没有获取到辅助权限, 确认后请清理后手动获取")
//            #else
//            // 打开请求辅助权限窗口
//            let _ = NoAccessView().openInWindow(title: "请求授权", sender: self)
//            #endif
//        }

        // 设置
        menu.makeMenuButton()
        
        AppHelper.addKeyEvent {
            AppLog.debug("cmd + j")
//            if (self.hisViewWin == nil){
//                self.hisViewWin = HistoryView().showViewOnNewWindow()
//            }
            self.hisViewWin?.close()
            self.hisViewWin = AlertHistoryView().showViewOnNewWindow()
        }
        
    }
    
    func windowDidResignKey(_ notification: Notification) {
        // 关闭窗口
        self.hisViewWin?.close()
    }
    
    
}

